/**
 * Created by Foold on 2014-5-18.
 */
var log4js = require('log4js');



log4js.configure({
    appenders: [
        { type: 'console' },
        {
            type:'dateFile',
            filename: 'logs/west2',
            pattern: "-yyyy-MM-dd.log",
            category: 'west2',
            maxLogSize: 1024,
            alwaysIncludePattern: true
        }
    ],
    replaceConsole: true
});
exports.allowed=function(){

    return [
        /^\/login/,
        /^\/signin/,
        /^\/logout/,
        /^\/child/,
        /^\/mainmenu/,
        /^\/images/,
        /^\/image/,
        /jsonall$/,
        /^\/detail/,
        /^\/test/

    ];
};

exports.mongoconfig = function(){

    var opts = {
        "database": "west2",
        "host": "localhost",
        "port": 27017
    };

    opts['url'] = "mongodb://"+opts.host+":"+opts.port+"/"+opts.database;


    return opts;

}


exports.logInit=function(app){

    app.use(log4js.connectLogger(this.logger('west2'), { level: log4js.levels.INFO }));

}

exports.logger = function(name){
    var logger = log4js.getLogger(name);
    logger.setLevel('INFO');
    return logger;
}

